{% extends 'myadmin/base.html' %}

{% block cc %}
<title>Book-Shop会员修改</title>
{% endblock %}

{% block con %}
<div class="row-content am-cf">
    <div class="row  am-cf">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">会员修改表单</div>
                    <div class="widget-function am-fr">
                        <a href="javascript:;" class="am-icon-cog"></a>
                    </div>
                </div>
                <div class="widget-body am-fr">

                    <form class="am-form tpl-form-line-form" action="{% url 'myadmin_users_update' %}" method="post" enctype="multipart/form-data">
                        {% csrf_token %}
                        <input type="hidden" name="id" value="{{ obj.id }}">
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                *手机号
                            </label>
                            <div class="am-u-sm-9">
                                <input type="text" name="phone" value="{{ obj.phone }}" required maxlength="11" minlength="11" class="tpl-form-input" placeholder="请输入手机号码">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                *密码
                            </label>
                            <div class="am-u-sm-9">
                                <input type="hidden" name="old_password" value="{{ obj.password }}" required minlength="6" maxlength="18" class="tpl-form-input" placeholder="请输入密码">
                                <input type="password" name="password" value="{{ obj.password }}" required minlength="6" maxlength="18" class="tpl-form-input" placeholder="请输入密码">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                头像
                            </label>
                            <div class="am-u-sm-9">
                                <div class="am-form-group am-form-file">
                                    <div class="tpl-form-file-img">
                                        <img class="topimg" src="{{ obj.face }}" alt=""style="width: 100px;">
                                    </div>
                                    <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                        <i class="am-icon-cloud-upload"></i>
                                         添加头像
                                    </button>
                                    <input id="doc-form-file" name="face" type="file" multiple="">
                                    <input id="doc-form-file" name="old_face" type="hidden" value="{{ obj.face }}" multiple="">
                                </div>

                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                昵称
                            </label>
                            <div class="am-u-sm-9">
                                <input type="text" name="nickname" value="{{ obj.nickname }}" class="tpl-form-input" placeholder="请输入昵称">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                居住地址
                            </label>
                            <div class="am-u-sm-9">
                                <input type="text" name="homeaddress" value="{{ obj.homeaddress }}" class="tpl-form-input" placeholder="请输入地址">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                性别
                            </label>
                            <div class="am-u-sm-9">
                                    <label class="am-radio-inline"><input type="radio" name="sex" {% if obj.sex == '1' %} checked {% endif %} value="1"> 男</label>
                                    <label class="am-radio-inline"><input type="radio" name="sex" {% if obj.sex == '0' %} checked {% endif %} value="0"> 女</label>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label class="am-u-sm-3 am-form-label">
                                身份类别
                            </label>
                            <div class="am-u-sm-9">
                                <select data-am-selected="{searchBox: 1}" name="usertype" style="display: none;">
                                    <option value="0">本科</option>
                                    <option value="1">专科</option>
                                    <option value="2">研究生</option>
                                </select>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button class="am-btn am-btn-primary tpl-btn-bg-color-success ">
                                    提交
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $('input[name=face]').change(function () {
        var file=this.files[0];
        var reader=new FileReader();
        reader.readAsDataURL(file);
        reader.onload=function (e) {
            $('.topimg').attr('src',this.result)
        }
    })
</script>
{% endblock %}


